package behaviorTree

import (
	"fmt"
	"strconv"
)

type NodeState int32

const (
	INVALID NodeState = -1

	FAILURE NodeState = 0
	SUCCESS NodeState = 1
	BEGIN   NodeState = 2
	RUNNING NodeState = 3

	NodeStateMax NodeState = 4
)

func init() {
	AddNodeState(int32(INVALID), "INVALID")
	AddNodeState(int32(BEGIN), "BEGIN")
	AddNodeState(int32(RUNNING), "RUNNING")
	AddNodeState(int32(FAILURE), "FAILURE")
	AddNodeState(int32(SUCCESS), "SUCCESS")
}

var NodeState_name = map[int32]string{}
var NodeState_value = map[string]int32{}

func AddNodeState(val int32, name string) {
	_, existed := NodeState_name[val]
	if existed {
		panic(fmt.Sprintf("NodeState val is dup, %s:%d", name, val))
	}
	NodeState_name[val] = name
	NodeState_value[name] = val
}
func (x NodeState) String() string {
	return NodeState_enumName(NodeState_name, int32(x))
}
func NodeState_enumName(m map[int32]string, v int32) string {
	s, ok := m[v]
	if ok {
		return s
	}
	return strconv.Itoa(int(v))
}
